/*
The surface-physics project: http://code.google.com/p/surface-physics/
Adds real world physics based on the Bullet physics engine, to bases in the Orbiter space
flight simulation software.

Written by Abhijit Nandy
License : Apache License 2.0

Bump_BaseObject.cpp

This file implements a common class for a pointer that can  point at different type of objects.
Also contains the world transform m[16] that is a common member to both objects types
and thus can be factored out, into this class.

*/


/* Class declaration */
#include "Bump_BaseObject.h"




Bump_BaseObject::registry_map&
Bump_BaseObject::registry()
{
    static registry_map impl;
    return impl;
}


/**
 * Create an instance of the object from the class name
 */
Bump_BaseObject *
Bump_BaseObject::instantiate(std::string const & name)
{
    auto it = Bump_BaseObject::registry().find(name);
    return it == Bump_BaseObject::registry().end() ? nullptr : (it->second)();
}


bool
Bump_BaseObject::checkRegistry(std::string const & name)
{
    auto it = Bump_BaseObject::registry().find(name);
    return it == Bump_BaseObject::registry().end() ? false : true;
}


/**
 * Constructor for the class. Does nothing.
 */
Bump_BaseObject::Bump_BaseObject()		
{
	//Default object control settings
	deleteMe = false;
	physicsInited = false;
	deleteIfInactive = false;

	mPreStepFrequency = 0;
	mPostStepFrequency = -1;
	updateWhenFrozen = false;
	strcpy(className, "BaseObject");

	bumpBase = NULL;
	hObjThis = NULL;
	strcpy(strObjectName, "UNNAMED");

}


/**
 * Destructor, does nothing currently
 */
Bump_BaseObject::~Bump_BaseObject()
{
}


int
Bump_BaseObject::clbkSetClassCaps(InitialObjectData& initialData)
{
	//DebugBreak();

	strcpy(strObjectName, initialData.strObjName);
	hObjThis = initialData.hObj;
	bumpBase = initialData.base;

	return 0;
}


int
Bump_BaseObject::clbkPreStep(double SimT, double SimDT, double MJD)
{
	//DebugBreak();
	return 0;
}


int
Bump_BaseObject::clbkPostStep(double SimT, double SimDT, double MJD)
{
	return 0;
}


int
Bump_BaseObject::clbkLoadState(FILEHANDLE file)
{
	return 0;
}


int
Bump_BaseObject::clbkSaveState(FILEHANDLE file)
{
	return 0;
}


int
Bump_BaseObject::clbkPhysicsRender(void)
{
	return 0;
}


int
Bump_BaseObject::clbkRemoveFromSim()
{
	return 0;
}

int
Bump_BaseObject::clbkReset()
{
	return 0;
}

void
Bump_BaseObject::clbkSetFocus()
{
	// Do nothing by default
}




